namespace DesignPattern.Behavioral.Memento
{
    public class MementoPattern
    {
        public static void Test()
        {
            var originator = new Originator();
            var careTaker = new CareTaker();

            originator.SetState("State #1");
            originator.SetState("State #2");
            careTaker.Add(originator.SaveStateToMemento());
            originator.SetState("State #3");
            careTaker.Add(originator.SaveStateToMemento());
            originator.SetState("State #4");

            System.Console.WriteLine($"Current state: {originator.GetState()}");
            originator.GetStateFromMemento(careTaker.Get(0));
            System.Console.WriteLine($"First saved state: {originator.GetState()}");
            originator.GetStateFromMemento(careTaker.Get(1));
            System.Console.WriteLine($"Second saved state: {originator.GetState()}");
        }
    }
}